<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加计划单</title>
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<style>
		body{background: #Fff;} .overlay, .overlay select, .overlay .form-dropdown { width: 142px; }
		.form>form>div label{width:100px;text-align:right;display: inline-block;}
		.form>form>div label.error{width:auto;}
		</style>
	</head>

	<body>
		<div class="form" style="padding:40px;">
			<input type="hidden" value="" class="productId"  />
			<form class="block-form" id="commentForm">
				<div style="margin-top:0px;">
					<label><span class="red">*</span>计划单名称：</label>
					<input type="text" class="plan_name" placeholder="请输入计划单名称" name="plan_name" />
				</div>
				
				<div>
					<label><span class="red">*</span>计划单产品：</label>
					<div class="overlay">
						<!--这个是用来存放选中的select的值的-->
						<input type="hidden" value="" class="form-select-value" id="plan_product" />
						<div class="dropdown">
							<button class="dropdown-toggle form-dropdown" type="button">
				                    <span class="value text-ellipsis pro_catevalue">请选择计划单产品</span>
				                    <span class="caret"></span>
				            </button>
				            <ul class="none">
								<li data-value='001'>请选择</li>
								<li data-value='002'>老白干测试系列</li>
								<li data-value='003'>鸿兴酒</li>
								<li data-value='004'>小白干</li>
								<li data-value='001'>二锅头</li>
							</ul>
						</div>
					</div>
					<input type="text" value="" class="form-select-value" name="plan_product"  style="visibility: hidden; width:0px;" />
				</div>
				
				<div>
					<label><span class="red">*</span>印码类型：</label>
					<input type="radio" name="proname"  class="radio"  value="1" checked="true"/>瓶码
					<input type="radio" name="proname"  class="radio" value="2"/>盒码
					<input type="radio" name="proname"  class="radio" value="3" />箱码
					<input type="radio" name="proname" class="radio"  value="4" />标签
				</div>
				<div id="showpingma">
					<label class="hidden"><span class="red">*</span>印码类型：</label>
					<input type="radio" name="pingma"  class="radio"  value="5"/>内码
					<input type="radio" name="pingma"  class="radio"  value="6"/>内外码
				</div>
			 
				<div>
					<label><span class="red">*</span>包材供应商：</label>
					<!--如果没有包材供应商-->
					<span class="red none">没有对应包材供应商，请联系在乎传媒运营人员确认。</span>
					<!--如果有包材供应商-->
					<div class="overlay ">
						<!--这个是用来存放选中的select的值的-->
						<input type="hidden" value="" class="form-select-value" id="producer" />
						<div class="dropdown">
							<button class="dropdown-toggle form-dropdown" type="button">
				                    <span class="value text-ellipsis pro_catevalue">请选择包材供应商</span>
				                    <span class="caret"></span>
				            </button>
				            <ul class="none">
								<li data-value='001'>请选择</li>
								<li data-value='002'>在乎传媒</li>
								<li data-value='003'>丽鹏</li>
							</ul>
						</div>
					</div>
					<input type="text" value="" class="form-select-value" name="producer"  style="visibility: hidden; width:0px;" />
				</div>
				
				<div>
					<label><span class="red">*</span>印码数量：</label>
					<input type="text" class="pro_name" placeholder="请输入印码数量" name="pnumber" id="pnumber"/><span style="padding-left:8px;">每次生产数量1-100万之间</span>
				</div>
				<div>
					<label><span class="red">*</span>截止时间：</label>
					<input type="text" class="Wdate" onclick="WdatePicker()" name="deadline"/>
				</div>
				 <div>
					<label><span class="red hidden">*</span>合同编号：</label>
					<input type="text" class="pro_name" placeholder="请输入合同编号" name="hetong" />
				</div>
				
				<div>
					<label><span class="red hidden">*</span>备注信息：</label>
					<textarea style="width:442px;height:163px;vertical-align: top;" class="pro_desc" name="desc"></textarea>
				</div>
				
				<div>
					<label  class="hidden"><span class="red hidden">*</span>产品名称：</label>
					<input type="submit" value="保存" class="search-input-button bgblue" id="subButton" />
				    <input type="button" value="返回" class="search-input-button " id="backButton" />
				</div>
			</form>
		</div>

		<script src="js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/js.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/wdatePicker/WdatePicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery.cxselect.js" type="text/javascript" charset="utf-8"></script>
	    <script src="js/scroll/jquery.slimscroll.min.js" type="text/javascript" charset="utf-8"></script>
	    <script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
		<script>
		var index = parent.layer.getFrameIndex(window.name); /*获取窗口索引*/
		$("#backButton").click(function(){
			parent.layer.close(index);
		})
		$.validator.setDefaults({
			submitHandler: function() {
				//这里放验证成功之后要执行的函数
				parent.layer.close(index);
			}
		});

		//这里是验证省市
		$.validator.addMethod("isproductEmpty", function(value, element) {
			if($('#plan_product').val()){
				return true;
			}else{return false;}
		}, "<i class=\" icon icon_error_red \"></i>请选择计划单产品！");
		
		//这里是验证产品类型
		$.validator.addMethod("isproducerEmpty", function(value, element) {
			console.log('eee');
			if($('#producer').val()){
				return true;
			}else{return false;}
		}, "<i class=\" icon icon_error_red \"></i>请选择包材供应商！");
		
		//这里是验证是否为正整数
		$.validator.addMethod("isIntegral", function(value, element) {
			var value=$('#pnumber').val();
 			//满足条件
			 if((/^(\+|-)?\d+$/.test( value )) && value > 0){  
				return true;
			}else{return false;}
		}, "<i class=\" icon icon_error_red \"></i>印码数量必须为正整数！");
		
		
		$(document).ready(function() {
			commonObj.checkinit();
			
			showPingma();
			$("#commentForm").validate({
				rules: {
					plan_name: {
						required: true,
					},
					plan_product:{
						isproductEmpty: true,
					},
					producer: {
						isproducerEmpty: true,
					},
					pnumber: {
						required:true,
						isIntegral: true,
					},
					deadline: {
						required: true,
					},
				},
				messages: {
					plan_name: {
						required: "<i class=\" icon icon_error_red \"></i>计划单名称",
					},
					pnumber: {
						required: "<i class=\" icon icon_error_red \"></i>请输入印码数量",
					},
					deadline: {
						required: "<i class=\" icon icon_error_red \"></i>请选择截止日期",
					},
				},
				errorPlacement: function(error, element) {
					error.appendTo('<i class=\" icon icon_error_red \"></i>').appendTo(element.parent());
				},
			});
		});
		
		function showPingma(){
			var pronameVal=$('input[name="proname"]:checked').val();
			if(pronameVal==1){
					$('#showpingma').show();
			}else{
					$('#showpingma').hide();
			};
			$('input[name="proname"]').click(function(){
				pronameVal=$('input[name="proname"]:checked').val();
				if(pronameVal==1){
					$('#showpingma').show();
				}else{
					$('#showpingma').hide();
				}
			})
		}
		 
		</script>

	</body>

</html>